
namespace BiztalkBuildHelper
{
    using System;
    using System.IO;
    using System.Collections;
    using System.Collections.Generic;
    using BiztalkBuildHelper;
    using System.Diagnostics;

    class SlnParser
    {

        public static void Main(String[] args)
        {
            List<SolutionParser.Vs2005Project> projects;
            if (args == null || args.Length < 2)
            {
                Console.WriteLine("Pass 2 Parameters :SolutionFileName NewVersionToUpdate");
                Console.ReadLine();
                return;
            }
            string filename = args[0];  //@"F:\SUNDAR\books\BusinessProcessManagementApplications.sln";
            string strNewVersion = args[1]; 
            projects = SolutionParser.GetListofProjects(filename);
            if (projects == null)
                return;
            string strSolnFullPath = System.IO.Path.GetFullPath(filename);
            string strDirPath = System.IO.Path.GetDirectoryName(strSolnFullPath); 
            foreach (SolutionParser.Vs2005Project project in projects)
            {
                if (project.ProjectType != SolutionParser.EnumProjType.btproj)
                    continue;
                Console.WriteLine(project.ProjectName);
                Console.WriteLine(project.Path);
                try
                {
                    SolutionParser.UpdateBizTalkProjVersion(Path.Combine(strDirPath,    project.Path), strNewVersion );    
                }
                catch (Exception ex)
                {
                    Console.WriteLine(project.Path + " " +  ex.Message); 
                } 
            }

            Console.ReadLine();  


        }
        //////////////////////////

    }
}
